home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
4_0
/
ORBIT_SO
/
EASYDIAL.H
< prev
next >
Wrap
Text File
|
1992-07-19
|
5KB
|
121 lines
/* Include files for my easy dialog handler */
/* Copyright 1987 */
/* David Palmer */
/* Mail code 220-47 */
/* California Institute Of Technology */
/* Duplication, modification, and examination allowed on a */
/* non-commercial basis only. Commercial use prohibited */
/* without prior written agreement with the author. (This */
/* includes sale by for-profit companies, and use as an */
/* inducement to buy something.) */
/************************Description*************************/
/*
* EasyDialog.h is a package to allow data-driven dialog
* boxes. This package is incomplete, badly documented,
* and subject to revision. On the other hand, it does have
* flaws.
* The main entry point in this package is "EasyDialog()"
* Its definition is:
* int EasyDialog(id, pedi)
* int id;
* EDITEM *pedi;
* It returns the itemnumber of the final button pushed. (A button
* is final if it has no associated procedure, or if the associated
* procedure returns a non-zero value. More about this later)
* The id is the resource number of the dialog, pedi points to
* an array of EDITEMs. (ED stands, of course, for EasyDialog)
* The definition of EDITEM is included in this file. The elements of
* the structure are:
*
* int nitems;
* int firstitem;
* These are the number of items in a set, and the itemnumber
* (dialog item number) of the first in the set. For radio buttons,
* a set defines a group of which only one may be turned on at one
* time. For other item types, the elements of a set are independant
* enum EDItemType itemtype;
* This element determines the behaviour of the item. If it does
* not correspond to the actual type of the dialog item, you may
* have trouble. edchars, edstrings, edints, and edfloats require an
* item of editable text, the remainder are self-explanatory
* except for edlast, which is an itemtype indicating the end
* of the array of EDITEMs. (You must have one of these, or
* dire things will happen.)
* void *pvalue;
* A pointer to the value or set of values controlled by the
* dialog items in the EDITEM. For radio buttons, the value
* is set to the number of the button pressed, starting from
* one for the first of the set. For strings, it points to an array
* of 256-character arrays which are set to C strings. For
* check-boxes, it points to an array of integers set to -1 or 0,
* depending on the final state of the checkboxes. for ints
* floats, and chars, it points to an array of the appropriate
* type, which is set to the entered values.
* int finit;
* A boolean which tells whether the dialog should be set up to
* display the original values pointed to by pvalue. Otherwise
* it leaves buttons and check-boxes empty and editable text
* null.
* int (*pfunc)();
* A pointer to a function to be called when one of the items in
* the set is modified. Called as
* (*(pedihit->pfunc))(pdi, pedi, pedihit, itemnum)
* where pdi is the pointer to the dialog, pedi is a pointer
* to the array of EDITEMs, pedihit is a pointer to the
* particular EDITEM containing the modified item. The
* itemnum is the dialog item number. If the function returns
* a non-zero value, EasyDialog immediately returns that value.
* Otherwise, it continues.
*
* This package desparately needs an example to make itself clear.
* The orbit program uses this package for three different dialogs.
* Dialogs handlers are ordinarily so tedious to write that this
* package paid back the time required to write it in this program
* alone. (At least it was more fun to write :-)
* The orbit program, and EasyDialog are bundled together in this
* posting.
*/
#ifndef TRUE
#define TRUE -1
#define FALSE 0
#endif
#ifndef NULL
#define NULL (0l)
#endif
#define Bool10(f) ((f) ? 1 : 0 )
#define MAXEDCCH 256 /* spacing between text strings in array */
enum EDItemType {
edlast, /* no more items */
edbutton, /* button set */
edchar, /* a single character */
edstring, /* a string of characters <= 242 characters*/
edint, /* a standard length integer */
edfloat, /* a double precision floating point number */
edrad, /* radio button set */
edcheck, /* a check box */
edscpair /* a scroll bar, editable value pair */
/* (to be implemented) */
};
typedef struct {
int nitems; /* number of items in set */
int firstitem;
enum EDItemType itemtype; /* what type of item set */
void *pvalue; /* pointer to first value of right type */
int finit; /* whether to initialize the data */
int (*pfunc)(); /* function to execute, called as: */
} EDITEM; /* (*(pedihit->pfunc))(pdi, pedi, pedihit, itemnum)*/
/***************** Not yet implemented *****************/
typedef struct {
int min, max; /* minimum and maximum values */
int thumbstep, arrowstep; /* change in value for thumb or arrow */
int value;
} EDSCPAIRTYPE;